﻿using System;
using Aeon.Framework.Objects;

namespace Aeon.Framework
{

/// <summary>
/// Value object for native lighting instantiation.
/// [TODO] Directional lights.
/// 
/// </summary>
public sealed class AeonLight : IKey, IMove, ITurn
    {
    // --- Attributes:
    
    private String key;             // Light identifier.
    private Boolean spot;           // Directional flag. 

    private Position origin;        // Light position.
    private Orientation angle;      // Light orientation.
    
    private AeonColor amb;          // Ambient component.
    private AeonColor dif;          // Diffuse component.
    private AeonColor spc;          // Specular component.
        
    // --- Properties:
    
    public String ID { get { return(key); } }
    public Position Origin { get { return(origin); } }
    public Orientation Angle { get { return(angle); } }
    
    internal Single[] VectorAmbient  { get { return(new float[]{ amb.R, amb.G, amb.B, amb.A }); } }
    internal Single[] VectorDiffuse  { get { return(new float[]{ dif.R, dif.G, dif.B, dif.A }); } }
    internal Single[] VectorSpecular { get { return(new float[]{ spc.R, spc.G, spc.B, spc.A }); } }
    
    internal Single[] VectorPosition
        {
        get {
            float w = (spot) ? (0.0f):(1.0f);
            return(new float[]{ origin.xPos, origin.yPos, origin.zPos, w });
            }
        }

    // --- Constructor:

    public AeonLight(String key, Position position, AeonColor ambient, AeonColor diffuse, AeonColor specular)
        {
        this.key = key;
        spot = false;
        
        origin = position;
        angle = Orientation.Origin; // [TODO] Actually implement ITurn.
         
        amb = ambient; 
        dif = diffuse;
        spc = specular;
        }
        
    // [TODO] Default static property for simple white light? 
    // Glfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    // Glgloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
    // Glfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
    
    // --- Public Methods:
    
    public void MoveTo(Position pos) { origin.Change(pos); }
    public void MoveBy(IVector vec) { origin.Transform(vec); }

    public void RotateTo(Orientation ang) { angle.Change(ang); }
    public void RotateBy(Orientation ang) { angle.Transform(ang); }
    }


}